layui.use(['layer', 'form', 'ztree', 'laydate', 'admin', 'ax', 'table', 'func', 'dict', 'formSelects', 'xmSelect','upload'], function () {
    var form = layui.form;
    var $ax = layui.ax;
    var table = layui.table;
    var func = layui.func;
    var upload = layui.upload;
    var $ = jQuery = layui.jquery;
    var dict = layui.dict; //获取自定义模块
    var formSelects = layui.formSelects;
    var xmSelect = layui.xmSelect;
    var laydate = layui.laydate;
    dict.renderDictAll(); //渲染
    //table的初始化实例

    //重新渲染select数据
    form.render('select');

    /**
     * 系统管理--菜单管理
     */
    var Menu = {
        tableId: "menuTable",    //表格id
        condition: {
            menuId: "",
            menuName: "",
            level: ""
        }
    };
    //宽度大小
    var sm = 110;
    var nor = 150;
    var lg = 180;
    var bt = 220;
    /**
     * 初始化表格的列
     */
    Menu.initColumn = function () {
        return [[
            {field: 'memberName', sort: true, title: '会员名称'},
            {field: 'memberGrade', sort: true, title: '会员等级',templet: function (data) {
                    var grade = data.memberGrade;
                    if (grade == '01') {
                        return '普通';
                    }
                    if (grade == '02') {
                        return '白银';
                    }
                    if (grade == '03') {
                        return '黄金';
                    }
                    if (grade == '04') {
                        return '钻石';
                    }
                    return '未知';
                }},

            {field: 'membershipDate', sort: true, title: '入会时间'},
            {field: 'orderCount', sort: true, title: '点单次数'},
            {field: 'orderTotalAmount', sort: true, title: '总点单金额(元)'}
        ]];
    };


    Menu.initTable = function(queryData) {
        var path = '/erya/member/queryAll';
        if (queryData) {
            path += '?' + queryData;
        }
        return table.render({
            elem: '#' + Menu.tableId,
            url: Feng.ctxPath + path,
            page: true,
            height: "full-98",
            cellMinWidth: 100,
            cols: Menu.initColumn(),
        });
    }

    // 搜索
    $('#btnQuery').click(function () {
        var memberCode = $('#memberCode').val().trim();
        var memberGrade = $('#memberGrade').val().trim();
        Menu.initTable('memberName=' +　memberCode + '&memberGrade=' + memberGrade);
    });

    Menu.initTable(null);
});